package com.html2rss.plugins;

import org.apache.struts.action.PlugIn;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.config.ModuleConfig;

import javax.servlet.ServletException;

import com.html2rss.core.parser.HTMLFeedExtracter;
import com.dappit.Dapper.parser.MozillaParser;

/**
 * User: vvs
 * Date: 07.04.2007
 * Time: 20:06:20
 */
public class InitializationPlugIn implements PlugIn {
    private String mozillaLibBaseDirectory ;
    private static MozillaParser parser;
    private String hostName;
    public static String appHostName;


    public static MozillaParser getParser() {
        return parser;
    }

    public String getMozillaLibBaseDirectory() {
        return mozillaLibBaseDirectory;
    }

    public void setMozillaLibBaseDirectory(String mozillaLibBaseDirectory) {
        this.mozillaLibBaseDirectory = mozillaLibBaseDirectory;
    }

    public void destroy() {
    }

    public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {

        try {
            HTMLFeedExtracter.initParser(mozillaLibBaseDirectory);
        } catch (Exception e) {
            throw new ServletException("Application initialization error",e);
        }
        parser = new MozillaParser();
    }

    public String getHostName() {
        return hostName;
    }


    public void setHostName(String hostName) {
        this.hostName = hostName;
        appHostName= hostName;
    }
}
